<template>
  <div v-show="PanelIsShow" class="op-group comp-op-filter">
    <div class="op-title">筛选</div>
    <template v-for="(modeInfo, modeIndex) in selectionSetting">
      <div
        v-if="modeInfo.showFunc(selectionInfo)"
        :key="modeInfo.selectionType"
        class="option-item"
      >
        <div class="title-row fixed">
          <span
            class="view-icon"
            title="预览"
            @mouseleave="onMouseLeave()"
            @mouseenter="onMouseEnter($event, modeInfo.selectionType)"
          >
            <img src="~@/assets/dataset/preview.png" alt="preview" />
          </span>
          <span class="label" :title="modeInfo.name(selectionInfo)">
            {{ modeInfo.name(selectionInfo) }}
          </span>
          <div class="btn-box">
            <a-button
              v-if="!modeInfo.isShowSub"
              class="op-btn"
              type="primary"
              size="small"
              @click="showDetail(modeInfo, modeIndex)"
              >确定</a-button
            >
            <div class="clear-float"></div>
          </div>
        </div>
        <div v-if="modeInfo.isShowSub" class="detail-panel">
          <h6 class="op-sub-title">操作</h6>
          <div
            v-for="(item, i) in modeInfo.actions"
            :key="i"
            class="sub-item"
            :class="{
              active: value === item.value,
            }"
            @click="onCheckItemClicked(item)"
          >
            <span class="check-item">
              <span
                class="view-icon sub-icon"
                title="预览"
                @mouseleave="onMouseLeave()"
                @mouseenter="onMouseEnter($event, item.value)"
              >
                <img src="~@/assets/dataset/preview.png" alt="preview" />
              </span>
              <Status :value="value === item.value" />
              <span class="label fixed">{{ item.label }}</span>
            </span>
            <split-panel
              v-if="item.bindKey === 'splitColumns'"
              ref="splitPanel"
              v-model="bindValue[item.bindKey]"
              :split-mode="item.value"
            >
            </split-panel>
            <div
              v-else-if="item.bindKey !== ''"
              :key="'input-' + i"
              class="replace-value-box fixed"
              :class="{
                active: value === item.value,
              }"
            >
              <span v-if="item.bindKey === 'extractColumn'" class="inputLabel">
                新列名:
              </span>
              <a-input
                :key="'input-' + modeIndex + '-' + i"
                v-model="bindValue[item.bindKey]"
                class="replace-value fixed"
                size="small"
                placeholder="Null"
                @input="onInput($event, item)"
                @blur="onColumnNameChanged(item.bindKey, item)"
                @focus="onColumnNameChanged(item.bindKey, item)"
              ></a-input>
            </div>
          </div>
          <div class="button-row">
            <a-button class="op-btn-sub" size="small" @click="cancel(modeInfo)"
              >取消</a-button
            >
            <a-button
              class="op-btn-sub"
              type="primary"
              size="small"
              @click="doOption"
              >确定</a-button
            >
          </div>
        </div>
      </div>
    </template>
  </div>
</template>
<script lang="ts">
import { isFunction, isArray } from 'lodash'
import DataStore, {
  OptionPreViewAction,
  SelectionInfo,
} from '@/store/modules/dataview'
import { Component, Vue, Watch } from 'vue-property-decorator'
import Status from '../common/status.vue'
import splitPanel from '../common/splitPanel.vue'
import OptionSettingCommon from '../common/vr-option-set-common'

interface SelectionSettingItem {
  /**
   * 是否展示
   */
  showFunc(info: SelectionInfo | null): boolean
  /**
   * 选中模式
   */
  selectionType: OptionPreViewAction
  /**
   * 选中模式名称
   */
  name(info: SelectionInfo | null): string

  /**
   * 操作选项
   */
  actions: Array<{
    label: string
    bindKey: string
    value: OptionPreViewAction
  }>

  /**
   * 是否展示操作选项面板
   */
  isShowSub: boolean
}

@Component({
  components: {
    Status,
    splitPanel,
  },
})
export default class SelectionFilter extends Vue {
  /** 选中设置 */
  public selectionSetting: Array<SelectionSettingItem> = [
    {
      showFunc(info: SelectionInfo | null) {
        return (
          info !== null &&
          info.selection !== '' &&
          info.isSameSelection === true
        )
      },
      selectionType: OptionPreViewAction.selectionFilterSelectCellsByKeyword,
      name: (info: SelectionInfo) => {
        return `筛选出包含 ${info.selection} 的单元格`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsByKeywordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsByKeywordReplaceContent,
        },
        {
          label: '抽取刷选内容形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsByKeywordExtractColumn,
        },
        {
          label: '根据所选内容将当前列拆分多列',
          bindKey: 'splitColumns',
          value:
            OptionPreViewAction.selectionFilterSelectCellsByKeywordSplitColumns,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsByKeywordDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsByKeywordKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isStartWith
      },
      selectionType:
        OptionPreViewAction.selectionFilterSelectCellsStartWithKeyword,
      name: (info: SelectionInfo) => {
        return `筛选出以 ${info.selection} 开头的单元格`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordExtractColumn,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isEndWidth
      },
      selectionType:
        OptionPreViewAction.selectionFilterSelectCellsEndWithKeyword,
      name: (info: SelectionInfo) => {
        return `筛选出以 ${info.selection} 结尾的单元格`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordExtractColumn,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isSelectionPos
      },
      selectionType:
        OptionPreViewAction.selectionFilterSelectCellsSamePosSelection,
      name: (info: SelectionInfo) => {
        return `筛选出包含文本位置 ${info.startIndex} - ${info.endIndex} 的单元格`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionExtractColumn,
        },
        {
          label: '根据刷选内容拆分列',
          bindKey: 'splitColumns',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionSplitColumns,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isWordPos
      },
      selectionType: OptionPreViewAction.selectionFilterSelectCellsSamePosWord,
      name: (info: SelectionInfo) => {
        return `筛选出该列与刷选单词 ${info.selection} 位置相同(${info.wordPos})的内容`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosWordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosWordReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosWordExtractColumn,
        },
        {
          label: '根据刷选单词位置所在内容拆分列',
          bindKey: 'splitColumns',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosWordSplitColumns,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosWordDeleteRows,
        },
        {
          label: '仅保单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsSamePosWordKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isStartWithWord
      },
      selectionType:
        OptionPreViewAction.selectionFilterSelectCellsStartWithSameWord,
      name: (info: SelectionInfo) => {
        return `筛选出单元格内容在 ${info.startWithWord} 单词之后的单词`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordExtractColumn,
        },
        {
          label: '根据刷选内容拆分多列',
          bindKey: 'splitColumns',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordSplitColumns,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isEndWithWord
      },
      selectionType:
        OptionPreViewAction.selectionFilterSelectCellsEndWithSameWord,
      name: (info: SelectionInfo) => {
        return `筛选出内容在 ${info.endWithword} 单词之前的单词`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordExtractColumn,
        },
        {
          label: '根据刷选内容拆分多列',
          bindKey: 'splitColumns',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordSplitColumns,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordKeepRows,
        },
      ],
      isShowSub: false,
    },
    {
      showFunc(info: SelectionInfo | null) {
        return info !== null && info.isEndWithWord && info.isStartWithWord
      },
      selectionType:
        OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWord,
      name: (info: SelectionInfo) => {
        return `筛选出内容在单词 ${info.startWithWord} 和 ${info.endWithword} 之间的单词`
      },
      actions: [
        {
          label: '替换当前所选单元格中刷选内容',
          bindKey: 'replaceKeyword',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordReplaceKeyword,
        },
        {
          label: '为所选单元格重新赋值',
          bindKey: 'replaceValue',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordReplaceContent,
        },
        {
          label: '抽取所选内容单独形成一列',
          bindKey: 'extractColumn',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordExtractColumn,
        },
        {
          label: '根据刷选内容拆分多列',
          bindKey: 'splitColumns',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordSplitColumns,
        },
        {
          label: '删除单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordDeleteRows,
        },
        {
          label: '仅保留单元格所在的行',
          bindKey: '',
          value:
            OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordKeepRows,
        },
      ],
      isShowSub: false,
    },
  ]

  get selectionInfo(): SelectionInfo | null {
    return DataStore.tableSelectionInfo
  }

  /**
   * 整个面板是否展示
   */
  get PanelIsShow() {
    return (
      this.selectionSetting.find((selectionInfo) => {
        return selectionInfo.showFunc(this.selectionInfo)
      }) !== undefined
    )
  }

  get tableSelctionText() {
    return DataStore.tableSelctionText
  }

  get vrResetTag() {
    return DataStore.vrResetTag
  }

  @Watch('vrResetTag')
  getResetTag() {
    this.selectionSetting.forEach((item) => {
      item.isShowSub = false
      if (DataStore.vrCurrenSetMode !== null) {
        DataStore.setTableVrCurrenSetMode(null)
      }
    })
  }

  value: string =
    OptionPreViewAction.selectionFilterSelectCellsByKeywordReplaceKeyword

  isShowSub: boolean = false

  replaceValue: string = 'Null'

  bindValue: any = {
    replaceKeyword: '',
    replaceValue: '',
    extractColumn: '',
    splitColumns: {
      separator: '',
      splitType: 1,
      splitNum: 2,
      columnName: [''],
    },
  }

  /**
   * 获取新的列名
   */
  getExtColumnName(columnName: string, BuildNames: Array<string> = []) {
    const columns = DataStore.tableColumns.reduce(
      (rec: Array<string>, item) => {
        rec.push(item.name)
        return rec
      },
      []
    )
    let i = 0
    let columnNameNew = ''
    do {
      i += 1
      columnNameNew = `${columnName}_字段${i}`
    } while (
      columns.includes(columnNameNew) ||
      BuildNames.includes(columnNameNew)
    )
    return columnNameNew
  }

  /**
   * 展示操作详情,需要线清对应的属性值并关闭其他已经打开的详情面板
   */
  showDetail(modeInfo: SelectionSettingItem, modeIndex: number) {
    const columnName: string = DataStore.tableSelectionInfo?.columnName || ''
    const newColumnName = this.getExtColumnName(columnName)
    modeInfo.isShowSub = true
    this.$set(this.bindValue, 'replaceKeyword', '')
    this.$set(this.bindValue, 'replaceValue', '')
    // 拆分成新列
    this.$set(this.bindValue, 'extractColumn', newColumnName)
    // 初始化拆分信息
    this.$set(this.bindValue, 'splitColumns', {
      separator: DataStore.tableSelectionInfo?.selection || '',
      splitType: 1,
      splitNum: 2,
      columnName: [
        newColumnName,
        this.getExtColumnName(columnName, [newColumnName]),
      ],
    })
    this.value = modeInfo.actions[0]?.value || ''

    this.selectionSetting.forEach((info, index) => {
      if (index !== modeIndex) {
        info.isShowSub = false
      }
    })
    switch (modeInfo.selectionType) {
      case OptionPreViewAction.selectionFilterSelectCellsByKeyword:
        OptionSettingCommon.setSelectionFilterSelectCellsByKeyword(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列中值包含 ${
            DataStore.tableSelectionInfo?.selection || ''
          } 的单元格`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithKeyword:
        OptionSettingCommon.setSelectionFilterSelectCellsStartWithKeyword(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列中以 ${
            DataStore.tableSelectionInfo?.selection || ''
          } 开头的单元格`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithKeyword:
        OptionSettingCommon.setSelectionFilterSelectCellsEndWithKeyword(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列中以 ${
            DataStore.tableSelectionInfo?.selection || ''
          } 结尾的单元格`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelection:
        OptionSettingCommon.setSelectionFilterSelectCellsSamePosSelection(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列单元格值位置在 ${DataStore.tableSelectionInfo?.startIndex} - ${DataStore.tableSelectionInfo?.endIndex} 的内容`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosWord:
        OptionSettingCommon.setSelectionFilterSelectCellsSamePosWord(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列单元格中单词值位置在 ${DataStore.tableSelectionInfo?.wordPos} 的内容`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWord:
        OptionSettingCommon.setSelectionFilterSelectCellsStartWithSameWord(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列单元格中单词 ${DataStore.tableSelectionInfo?.startWithWord} 后的单词`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWord:
        OptionSettingCommon.setSelectionFilterSelectCellsEndWithSameWord(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列单元格中单词 ${DataStore.tableSelectionInfo?.endWithword} 前的单词`
        )
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWord:
        OptionSettingCommon.setSelectionFilterSelectCellsStartWithAndEndWithSameWord(
          modeInfo.selectionType
        )
        this.$message.info(
          `已选出该列单元格中单词 ${DataStore.tableSelectionInfo?.startWithWord} 和 ${DataStore.tableSelectionInfo?.endWithword} 之间的单词`
        )
        break
      default:
        break
    }
  }

  @Watch('bindValue.splitColumns', {
    immediate: true,
    deep: true,
  })
  getSplitInfo() {
    DataStore.setTableSplitInfo({
      separator: (this.bindValue.splitColumns as any).separator,
      splitType: (this.bindValue.splitColumns as any).splitType,
      splitNum: (this.bindValue.splitColumns as any).splitNum,
      desc: '',
      newCol: (this.bindValue.splitColumns as any).columnName,
    })
  }

  onCheckItemClicked(item: any) {
    this.value = item.value
  }

  onInput(event: any, item: any) {
    this.$nextTick(() => {
      DataStore.setSelectionReplaceKeyword(this.bindValue.replaceKeyword)
      DataStore.setSelectionReplaceValue(this.bindValue.replaceValue)
      if (item.bindKey === 'extractColumn') {
        DataStore.setTableExtractColumnName(
          this.bindValue.extractColumn as string
        )
      }
    })
  }

  onMouseEnter(event: any, action: string) {
    const target = event.target as HTMLElement
    if (target) {
      DataStore.setPreviewAction(action)
      DataStore.setHoverYPos(target.getBoundingClientRect().top - 16)
    }
  }

  onMouseLeave() {
    DataStore.setHoverYPos(-1)
  }

  /** 字段名称更改 */
  onColumnNameChanged(key: string /* , item: any */) {
    // 如果该字段已经被使用，则自动填充一个合理的
    if (key === 'extractColumn') {
      this.$nextTick(() => {
        const newColumnName = this.bindValue[key]
        if (
          newColumnName === '' ||
          DataStore.tableColumns.find((column) => {
            return column.name === newColumnName
          })
        ) {
          this.bindValue[key] = this.getExtColumnName(
            DataStore.tableSelectionInfo?.columnName || newColumnName,
            []
          )
        }
      })
    }
  }

  validateSplitPanel(): Promise<any> {
    return new Promise((resolve, reject) => {
      let panel = this.$refs.splitPanel
      panel = isArray(panel) ? (panel as Array<any>)[0] : panel
      if (!panel) {
        reject(new Error('panel is not found'))
      } else if (isFunction((panel as any).validate)) {
        const result = (panel as any).validate()
        if (result) {
          resolve(result)
        } else {
          reject(result)
        }
      } else {
        reject(new Error('panel.validate is not a function'))
      }
    })
  }

  cancel(modeInfo: SelectionSettingItem) {
    modeInfo.isShowSub = false
    DataStore.setTableVrCurrenSetMode(null)
  }

  doOption() {
    if (!this.value) {
      this.$message.error('请选择相关操作')
      return
    }
    switch (this.value) {
      case OptionPreViewAction.selectionFilterSelectCellsByKeywordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出包含关键字的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsByKeywordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出包含关键字的单元格 > 为所选单元格重新赋值',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsByKeywordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出包含关键字的单元格 > 删除单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsByKeywordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc: '元格文字选中 > 筛选 > 选出包含关键字的单元格 > 仅保留所选行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsByKeywordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出包含关键字的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsByKeywordSplitColumns:
        this.validateSplitPanel().then((splitInfo: any) => {
          this.$emit('actiondone', {
            action: this.value,
            desc:
              '单元格文字选中 > 筛选 > 选出包含关键字的单元格 > 根据所选内容将当前列拆分多列',
            data: {
              brushValue: this.tableSelctionText,
              splitInfo,
            },
          })
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 替换选中的内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 替换刷选单元格的内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 删除单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithKeywordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 仅保留单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出以关键字结尾的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字结尾的单元格 > 替换刷选单元格的内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字结尾的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 删除单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsEndWithKeywordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以关键字开头的单元格 > 仅保留单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出以刷选内容位置一致的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出以刷选内容位置一致的单元格 > 替换当前所选单元格中的内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceValue,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以刷选内容位置一致的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionSplitColumns:
        this.validateSplitPanel().then((splitInfo: any) => {
          this.$emit('actiondone', {
            action: this.value,
            desc:
              '单元格文字选中 > 筛选 > 选出包含关键字的单元格 > 根据所选内容将当前列拆分多列',
            data: {
              brushValue: this.tableSelctionText,
              splitInfo,
            },
          })
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以刷选内容位置一致的单元格 > 删除所选行',
          data: {},
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosSelectionKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以刷选内容位置一致的单元格 > 仅保留所选行',
          data: {},
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosWordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出以刷选单词位置一致的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosWordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出以刷选单词位置一致的单元格 > 重置当前所选单元格内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break

      case OptionPreViewAction.selectionFilterSelectCellsSamePosWordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以刷选单词位置一致的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosWordSplitColumns:
        this.validateSplitPanel().then((splitInfo: any) => {
          this.$emit('actiondone', {
            action: this.value,
            desc:
              '单元格文字选中 > 筛选 > 选出以刷选单词位置一致的单元格 > 根据所选内容将当前列拆分多列',
            data: {
              brushValue: this.tableSelctionText,
              splitInfo,
            },
          })
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosWordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以刷选单词位置一致的单元格 > 删除所选行',
          data: {},
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsSamePosWordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出以刷选单词位置一致的单元格 > 仅保留所选行',
          data: {},
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出前面为word的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出前面为word的单元格 > 重置当前所选单元格内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break

      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordSplitColumns:
        this.validateSplitPanel().then((splitInfo: any) => {
          this.$emit('actiondone', {
            action: this.value,
            desc:
              '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 根据所选内容将当前列拆分多列',
            data: {
              brushValue: this.tableSelctionText,
              splitInfo,
            },
          })
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc: '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 删除所选行',
          data: {},
        })
        break
      case OptionPreViewAction.selectionFilterSelectCellsStartWithSameWordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc: '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 仅保留所选行',
          data: {},
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 替换关键字
       */
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出前面为word的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 单元格重新赋值
       */
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出前面为word的单元格 > 重置当前所选单元格内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 单元格重新赋值
       */
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 拆分成多列
       */
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordSplitColumns:
        this.validateSplitPanel().then((splitInfo: any) => {
          this.$emit('actiondone', {
            action: this.value,
            desc:
              '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 根据所选内容将当前列拆分多列',
            data: {
              brushValue: this.tableSelctionText,
              splitInfo,
            },
          })
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 仅保留所选行
       */
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc: '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 仅保留所选行',
          data: {},
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 仅保留所选行
       */
      case OptionPreViewAction.selectionFilterSelectCellsEndWithSameWordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出包含关键字的单元格 > 删除单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 替换关键字
       */
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordReplaceKeyword:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出前面为word的单元格 > 替换当前所选单元格中刷选内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceKeyword: this.bindValue.replaceKeyword,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 单元格重新赋值
       */
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordReplaceContent:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出前面为word的单元格 > 重置当前所选单元格内容',
          data: {
            brushValue: this.tableSelctionText,
            replaceValue: this.bindValue.replaceValue,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 单元格重新赋值
       */
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordExtractColumn:
        if (this.bindValue.extractColumn === '') {
          this.$message.error('请输入抽取列的列名')
          return
        }
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 抽取选中内容为一列',
          data: {
            brushValue: this.tableSelctionText,
            extractColumn: this.bindValue.extractColumn,
          },
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 拆分成多列
       */
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordSplitColumns:
        this.validateSplitPanel().then((splitInfo: any) => {
          this.$emit('actiondone', {
            action: this.value,
            desc:
              '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 根据所选内容将当前列拆分多列',
            data: {
              brushValue: this.tableSelctionText,
              splitInfo,
            },
          })
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 仅保留所选行
       */
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordKeepRows:
        this.$emit('actiondone', {
          action: this.value,
          desc: '单元格文字选中 > 筛选 > 选出前面为word的单元格 > 仅保留所选行',
          data: {},
        })
        break
      /**
       * 单元格文字选中 > 筛选 > 包含xxx，且前面有单词的单元格刷选出该单词 > 仅保留所选行
       */
      case OptionPreViewAction.selectionFilterSelectCellsStartWithAndEndWithSameWordDeleteRows:
        this.$emit('actiondone', {
          action: this.value,
          desc:
            '元格文字选中 > 筛选 > 选出包含关键字的单元格 > 删除单元格所在的行',
          data: {
            brushValue: this.tableSelctionText,
          },
        })
        break
      default:
        break
    }
  }
}
</script>
<style lang="less" scoped>
@import url('../op.less');
</style>
